#ifndef COMMON_H_
#define COMMON_H_

//file included
//les fichiers standards
#include <stdio.h>
#include <stdlib.h>
// les chaines de caracteres
#include <string.h>
//les socket
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//les thread
#include <pthread.h>
#include <regex.h>
#include <sys/resource.h>
//autres
#include <dirent.h>
#include<ctype.h>
#include <unistd.h>
//select
#include <sys/select.h>
//pour les semaphore
#include <sys/ipc.h>
#include <sys/sem.h>
#include <time.h>
#include <sys/time.h>
//Mode non bloquant
#include <fcntl.h>


#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CHK_ERR(v,m) if(v == -1) {perror(m); exit(1);}
#define closesocket(s) shutdown(s, SHUT_RDWR)
//taille d'une commande
#define BUFSIZE 1024
//taille du nom d'une commande
#define NAMESIZE 64


#define FDMAX 5/*nombre maximal de descripteur pour le readset du select serveur*/
#define NBTHREAD 4 /*le nombre de thread*/
//Protocole
#define MAX_TAILLE_OPTION 10
#define MAX_TAILLE_VALEUR 20
#define MAX_TAILLE_CMD 50

// Taille d'une addresse IPV4
#define TAILLE_IP 32
//defined types
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;

//Return type
typedef enum{
	RT_OK = 0,
	RT_ERR = -1,
} return_t;
//buffer_t
typedef struct buffer_t{
	char *data;
	size_t len;
} buffer_t;

buffer_t *create_buffer(char * data, int len);
return_t destroy_buffer(buffer_t *buf);

void print_addr(SOCKADDR_IN *addr);


#endif /*COMMON_H_*/
